/*
package com.pgtest.wsclient;

import org.apache.cxf.binding.soap.SoapHeader;
import org.apache.cxf.binding.soap.SoapMessage;
import org.apache.cxf.headers.Header;
import org.apache.cxf.helpers.DOMUtils;
import org.apache.cxf.interceptor.Fault;
import org.apache.cxf.phase.AbstractPhaseInterceptor;
import org.apache.cxf.phase.Phase;
import org.w3c.dom.Document;
import org.w3c.dom.Element;

import javax.xml.namespace.QName;
import java.util.List;

public class ClientLoginInterceptor extends AbstractPhaseInterceptor<SoapMessage>{

    private static String nameURI = "http://tempuri.org/";

    private String username;
    private String password;

    public ClientLoginInterceptor(String username, String password) {
        super(Phase.WRITE);
        this.username = username;
        this.password = password;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    @Override
    public void handleMessage(SoapMessage soapMessage) throws Fault {
        QName qName = new QName("MySoapHeader");
        Document document = DOMUtils.createDocument();

        Element root = document.createElementNS(nameURI,"MySoapHeader");
        Element username = document.createElement("username");
        Element password = document.createElement("password");

        username.setTextContent(this.username);
        password.setTextContent(this.password);
        root.appendChild(username);
        root.appendChild(password);

        SoapHeader header = new SoapHeader(qName,root);
        List<Header> headerList = soapMessage.getHeaders();
        headerList.add(header);
    }
}
*/
